//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
//     Copyright (c) Telligent Systems Corporation.  All rights reserved.
// </copyright> 
//------------------------------------------------------------------------------

// TODO: Remove code that display help...

using System;
using System.Web.UI;
using System.Web.UI.WebControls;

using CommunityServer.Components;
using CommunityServer.Controls;
using CommunityServer.Discussions.Components;

namespace CommunityServer.Discussions.Controls 
{
    // *********************************************************************
    //  RatingSummaryView
    //
    /// <summary>
    /// This server control is used to display who rated a post
    /// </summary>
    /// 
    // ********************************************************************/
    public class RatingSummaryView : TemplatedWebControl
    {
        #region Child Controls

        Repeater ratings;
        
        CSContext csContext = CSContext.Current;

        #endregion

        protected override void OnInit(EventArgs e) 
        {
            if (SkinName == null)                
                ExternalSkinFileName = "View-ThreadRatingSummary.ascx";
            else 
                ExternalSkinFileName = SkinName;
			
            base.OnInit(e);
        }
		
        protected override void OnLoad(EventArgs e) 
        {
            if (!Page.IsPostBack)
                DataBind();

            base.OnLoad(e);
        }

        #region DataBind

        public override void DataBind() 
        {
            base.DataBind();

            if (ratings != null)
            {
                ratings.DataSource = Ratings.GetRatings( RatingType.Thread, csContext.PostID );
                ratings.DataBind();
            }
        }
		
        #endregion		
		
        #region Skin
                
        protected override void AttachChildControls() 
        {
            ratings = (Repeater) FindControl("Ratings");
        }
		        
        #endregion
    }
}